<?php include $this->getViewFile('/common/Head') ?>
<body class="J_scroll_fixed">
<style>
.col-left{float:left}
.col-auto{overflow:hidden;_zoom:1;_float:left;}
.title-1{border-bottom:1px solid #eee; padding-left:5px}
.f14{font-size: 14px}
.lh28{line-height: 28px}
.blue,.blue a{color:#004499}
.gray4,a.gray4{color:#999;}
.lh22{line-height: 22px}
.lh25{line-height: 25px}
</style>
<div class="wrap J_check_wrap">
  <?php include $this->getViewFile('/common/Nav') ?>
  <div class="h_a">查找</div>

<?php $objForm = $this->beginWidget( 'CActiveForm', array('id' => 'searchForm','method' => 'get', 'action' => $this->createUrl('record')) ); ?>

  <div class="search_type cc mb10">
       <div class="mb10">
        关键字：
        <?php echo Form::select(array(1=>'买家会员名',2=>'买家UID',3=>'商品ID',4=>'订单号'),$formData['type'],'name="type"') ?>
        <input type="text" class="input length_2" id="keyword" name="keyword" style="width:200px;" value="<?php echo $formData['keyword'] ?>" placeholder="请输入搜索内容...">
        &nbsp;&nbsp;&nbsp;&nbsp;
        是否确定：<?php echo $objForm->dropDownList($model,'is_sure',RedeemRecordsModel::getSureHtmlList(),array('empty' => '全部')); ?>&nbsp;&nbsp;&nbsp;&nbsp;
        <!-- //NODE -->是否发货：<?php echo $objForm->dropDownList($model,'is_refund',RedeemRecordsModel::getRefundHtmlList(),array('empty' => '全部')); ?>&nbsp;&nbsp;&nbsp;&nbsp;

        是否提交订单：<?php echo Form::select(array(1=>'是',2=>'否'),$is_order_sn,'name="is_order_sn"','全部') ?>&nbsp;&nbsp;&nbsp;&nbsp;
        <br/><br/>
        订单提交时间：
        <input type="text" name="start_time" class="input length_2 J_date" value="<?php echo $start_time?>" placeholder="选择起始时间">
        -
        <input type="text" class="input length_2 J_date" name="end_time" value="<?php echo $end_time?>" placeholder="选择结束时间">

        <button class="btn">搜索</button>
      </div>
    </div>
<?php $this->endWidget(); ?>


  <div class="mb10"> 共有 ( <b><?php echo $count; ?></b> ) 条记录</div>
  <form name="myform" action="" method="post" class="J_ajaxForm">
    <div class="table_list">
      <table width="100%" cellspacing="0">
        <thead>
          <tr>
            <td align="center"><?php echo $sort->link('id') ?></td>
            <td>买家信息</td><!-- //NODE -->
            <td>备注信息</td>
            <td align="center">兑换商品</td>
            <td align="center">兑换积分</td>
            <td align="center">兑换时间</td>
            <td align="center">订单</td>
            <td align="center"><?php echo $sort->link('is_sure', '商家是否确定') ?></td>
            <td align="center"><?php echo $sort->link('is_refund', '是否发货') ?></td><!-- //NODE -->
            <td align="center">操作</td>
          </tr>
        </thead>
        <tbody>
         <?php
		 foreach($data as $rs){
		 ?>
         <tr>
            <td width="50" align="center"><?php echo $rs->id; ?></td>

            <td>
              <?php 
                
                $op[] = "ID:{$rs->uid},用户名:{$rs->username}</br>";
                $op[] = "邮箱:{$rs->MembersModel->email}</br>";
                $op[] = "手机:{$rs->MembersModel->phone}</br>";
                $op[] = "支付宝账号:{$rs->MembersModel->alipay}</br>";
                $op[] = "支付宝姓名:{$rs->MembersModel->alipay_name}</br>";

                $objMemberTaobao = MembersTaobaoModel::model()->find("uid = {$rs->uid}");
                if($objMemberTaobao)
                {
                  $op[] = '阿里旺旺:<b><a href="http://amos.im.alisoft.com/msg.aw?v=2&amp;site=cntaobao&amp;s=2&amp;charset=utf-8&amp;uid='.urlencode($objMemberTaobao->taobao_user_nick).'" target="_blank">'.$objMemberTaobao->taobao_user_nick.'<img src="http://amos.im.alisoft.com/online.aw?v=2&amp;site=cntaobao&amp;s=2&amp;charset=utf-8&amp;uid='.urlencode($objMemberTaobao->taobao_user_nick).'" alt=""></a></b>';
                }

                $op = implode('', $op);
                echo $op;
                unset($op);
                
               ?>
             </br>
             <a class="show_address" data-uid="<?php echo $rs->uid; ?>" href="javascript:void(0)">查看收获地址</a>
            </td>

            <td>
              <input data-id="<?php echo $rs->id ?>" type="text" name="remarks" value="<?php echo $rs->remarks ?>">
              <?php 
              /* //NODE
                $op[] = "ID:{$rs->seller_uid}</br>";
                $op[] = "邮箱:{$rs->MembersModel_seller->email}</br>";
                $op[] = "手机:{$rs->MembersInfoModel_seller->phone}</br>";
                $op[] = "支付宝账号:{$rs->MembersInfoModel_seller->alipay}</br>";
                $op[] = "支付宝姓名:{$rs->MembersInfoModel_seller->alipay_name}</br>";

                $objMemberTaobao = MembersTaobaoModel::model()->find("uid = {$rs->seller_uid}");
                if($objMemberTaobao)
                {
                  $op[] = '阿里旺旺:<b><a href="http://amos.im.alisoft.com/msg.aw?v=2&amp;site=cntaobao&amp;s=2&amp;charset=utf-8&amp;uid='.urlencode($objMemberTaobao->taobao_user_nick).'" target="_blank">'.$objMemberTaobao->taobao_user_nick.'<img src="http://amos.im.alisoft.com/online.aw?v=2&amp;site=cntaobao&amp;s=2&amp;charset=utf-8&amp;uid='.urlencode($objMemberTaobao->taobao_user_nick).'" alt=""></a></b>';
                }                  
              
                $op = implode('', $op);
                echo $op;
                unset($op);
                */
               ?>
            </td>


            <td align="center"><a href="<?php echo $rs->RedeemModel->title?>" target="_blank"><?php echo $rs->RedeemModel->title?></a></td>
            <td align="center"><?php echo $rs->integral ?></td>
            <td align="center"><?php echo date('Y-m-d H:i', $rs->record_time) ?></td>
            <td align="center"><?php echo $rs->order_sn ?><?php echo  !empty($rs->order_submit_time) ? '<br/>提交订单时间：<br/>'.date('Y-m-d H:i', $rs->order_submit_time) : '' ?></td>      
            <td align="center"><?php echo Form::select(RedeemRecordsModel::getSureHtmlList(),$rs->is_sure,'name="is_sure" data-id="'.$rs->id.'"'); ?></td>
            <td align="center"><?php echo Form::select(RedeemRecordsModel::getRefundHtmlList(),$rs->is_refund,'name="is_refund" data-id="'.$rs->id.'"'); ?></td>         
            <td align="center"><a data-title="<?php echo $rs->RedeemModel->title ?>" data-uid="<?php echo $rs->uid ?>" data-seller_uid="<?php echo $rs->seller_uid ?>" class="J_ajax_notice" href="javascript:void(0);"><font color='#FF00FF'>信息通知</font></a></td>
          </tr>
          <?php
		 }
		  ?>
        </tbody>
      </table>
      <div class="p10">
        <div class="pages"><?php echo $Page;?></div>
      </div>
    </div>
  </form>
</div>
<script src="<?php echo $staticUrl; ?>statics/js/common.js"></script>

<script type="text/javascript">

  function saveData(data, obj){
    Wind.use("artDialog", "iframeTools", function () {
      $.post('<?php echo AdminBase::U("recordEdit") ?>',data,function(rs){
        if(rs.status){
          art.dialog.tips('修改成功！', 1.5);
          $(obj).data('value',$(obj).val());
        }else{
          art.dialog.tips(rs.info, 3);
          $(obj).val($(obj).data('value'));
        }
        //重新加载
        //loads(data.id);
      },'json');
    });
  }

  function addFormValue()
  {
    var objs = $('input[data-id],select[data-id]');
    var length = objs.length;
    for(var i=0;i<length;i++)
    {
      var obj = objs.eq(i);
      var value = obj.val();
      obj.data('value',value);
    }    
  }


  $(function(){
    
    addFormValue();

    $('input[data-id],select[data-id]').change(function(){
      var id = $(this).data('id');
      var value = $(this).val();
      var title = $(this).attr('name');
      if(value != '' && id > 0){
        var data = {};
        data.id = id;
        data[title] = value;
        saveData(data, this);
        return true;
      }
      return false;
    });

    $(".J_ajax_notice").click(function(){
      var obj = $(this);
      var uid = obj.data('uid');
      var seller_uid = obj.data('seller_uid');
      var title = obj.data('title');
      var url = "<?php echo $this->createUrl('notice') ?>";
      Wind.use('artDialog','iframeTools', function () {
        var dialog = art.dialog({
          title: '信息通知',
          id: 'notice',
          lock: true,
          fixed: true,
          width:600,
          height:70,
          background: "#CCCCCC",
          padding:'5px 5px',
          opacity: 0,
          button:[{
            name:'确定',
            callback:function(){
              var uid = $("[name='uid']:checked").val();
              var notice = $("[name='notice']").val();
              if(!uid){
                alert('会员不能空');return false;
              }
              if(!notice){
                alert('商品信息不能空');return false;
              }
              $.getJSON(url,{notice:notice,uid:uid},function(data){
                alert(data.info);
                return true;
              });              
            },
            focus: true
          }],          
        });

        var data = '<div style="overflow:hidden;padding: 5px; ">\
        <form action="<?php echo AdminBase::U("notice") ?>" method="post" id="notice">\
        <div class="table_full">\
          <table width="100%" class="table_form contentWrap">\
             <tbody>\
           <tr>\
           <th width="80">会员</td>\
           <td>买家会员<input type="radio" checked name="uid" value="'+uid+'"/>商家会员<input type="radio" name="uid" value="'+seller_uid+'"/></td>\
           </tr>\
           <tr>\
           <th width="80">信息内容</td>\
           <td><textarea type="text" name="notice" cols="60" rows="3" style="height:50px;width:400px;">亲，您的商品('+title+')已经确定，请查看。</textarea></td>\
           </tr>\
           </tbody>\
           </table>\
        </div>\
        </form>\
        </div>';
        dialog.content(data);



      })
    })

  })
</script>

<script type="text/javascript">
$(function(){
  $(".show_address").click(function(){
    var uid = $(this).data('uid');
    $.getJSON('<?php echo $this->createUrl("public_ShowAddress") ?>', {uid: uid}, function(data){
      Wind.use('artDialog','iframeTools', function () {
        var dialog = art.dialog({
          title: '信息',
          lock: true,
          fixed: true,
          width:600,
          height:70,
          background: "#CCCCCC",
          padding:'5px 5px',
          opacity: 0,
                    
        });
        dialog.content(data.info);



      })      
    });
  })
})
</script>

</body>
</html>